define(['zepto', 'butterflysoc/components/dialog'], function($, Dialog){

    $(document).on('ajaxError', function(event, xhr, options, error){
        var text = xhr.responseText;
        var status = xhr.status;
        var url = options.url;
        if(url && url.substring(0,5)!="http:" && url.substring(0,6)!="https:") return;

        if(status == 200 && text && text.indexOf("index_real.html")>=0){
            var lasturl = window.location.href;
            return;
        }
        
        if(status == 0 && (!text || text == "")) {
            new Dialog({autoshow : true, target: 'body', title: '温馨提示',content: "请检查网络连接！"},
                {configs:[{title:'确定',eventName:'ok'}],
                    ok:function(){

                    }
                }
            );
            if($("#shade").length){
                $("#shade").remove();
            }
             if($(".cube-loader").length){
                $(".cube-loader").remove();
            }
             if($("#load_shade").length){
                $("#load_shade").remove();
            }
            
            return;
        }

        if(status == 200) {
            new Dialog({autoshow : true, target: 'body', title: '温馨提示',content: "网络状态不稳定或者可以尝试去掉网络代理！"},
                {configs:[{title:'确定',eventName:'ok'}],
                    ok:function(){
                        
                    }
                }
            );
            return;
        }
    });

    return $;
});